package com.tron.dobest.java.tronextend;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-05-13
 */
public class TronExtendStart {
    public static void main(String[] args) {
        Children children1 = new Children();
        /**
         * Base static{}   //类加载过程中执行，只执行一次
         * Children static{}   //类加载过程中执行，只执行一次
         * Base {}
         * Base init
         * Children{}
         * Children init
         */
        Children children2 = new Children();
        /**
         * Base {}
         * Base init
         * Children{}
         * Children init
         */

        //可以通过类访问类属性
        System.out.println(Children.b_static);
        //子类继承包权限属性
        System.out.println(children1.b_default);
        //子类继承继承权限属性
        System.out.println(children1.b_protected);
        //子类继承公开权限属性,如果同名属性,则访问子类属性
        System.out.println("children1.b_public: "+children1.b_public);

        children1.b_default_method();
        children1.b_protected_method();
        children1.b_public_method();

        Base base = new Base();
        base.b_public_method();

        System.out.println("======父类引用指向子类======");
        base = children1;
        //访问属性时,优先判断类型中的属性
        System.out.println(base.b_public);

        //访问方法时,优先看真实类型的方法。多态的实现
        base.b_public_method();

        children1.getSomeThing();

    }
}
